/*
 * adjacencia.h
 *
 *  Created on: 30/06/2011
 *      Author: george
 */

#ifndef ADJACENCIA_H_
#define ADJACENCIA_H_

#include <exception>
#include "adjnode.h"
#include "peer.h"
#include "session.h"

class Adjnode;
class Peer;

class DuplicatedPeerException: public std::exception{
public:
	virtual const char *what(){
		return "Item duplicado";
	}
};

class Adjacencia {
public:
	Adjnode *nullNode, *root;

	Adjacencia();

	void splay(const Peer &peer, Adjnode *&t);
	Session * insert(Peer *info);
	bool isEmpty();
	Adjnode *find(Peer *info);

private:
	void rotateWithLeftChild(Adjnode *&t);
	void rotateWithRightChild(Adjnode *&t);
};

#endif /* ADJACENCIA_H_ */
